const util = require('../../../../utils/util.js')
import { facePayList } from '../../../../api/payment'
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pageNum: 1,
    pageSize: 20,
    detailedList: [],
    currentTab:0
  },
    loadList() {
      if (this.data.pageNum == 1) {
        this.data.detailedList = []
      }
      facePayList({
        pageSize: this.data.pageSize,
        pageNum: this.data.pageNum,
        status:this.data.currentTab
      }).then(res => {
        res.data.data.forEach(item => {
          item.createDate = util.datetimeFormat(item.createDate)
          item.thumbnail = 'http://cdn.rzico.com/v4.0/wallet-consumption.png'
          this.data.detailedList.push(item)
        })

        this.setData({
          detailedList: this.data.detailedList
        })
      })

  },

  // 确认收款
  paymentClick(item){
    wx.navigateTo({
      // url: '/pages/member/share/accounts/account?id='+item.currentTarget.dataset.item.id,
       url: '/pages/member/share/determinePage/qRCodePayment?id='+item.currentTarget.dataset.item.id,
    })
  },

    //  tab切换逻辑
    swichNav: function(e) {
      var _this = this;
      if (e !== undefined) {
        if (this.data.currentTab === e.target.dataset.current) {
          return false;
        } else {
          _this.data.pageSize = 20
          _this.data.pageNum = 1
          _this.data.currentTab = e.target.dataset.current
          _this.loadList()
          _this.setData({
            currentTab: e.target.dataset.current
          })
        }
      }
    },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  onShow:function(){
    this.data.pageNum=1,
    this.data.pageSize=20,
    this.loadList()
  },

  onPullDownRefresh() {
    wx.showNavigationBarLoading()
    this.data.pageNum = 1
    setTimeout(() => {
      wx.hideNavigationBarLoading()
      this.loadList()
      wx.stopPullDownRefresh()
    }, 1000);
  },

  onReachBottom() {
    this.data.pageNum += 1
    this.loadList()
  },

})
